package com.ruoyi.zsyh.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsyh.domain.ZsyhPlatformSellpartsspecial;
import com.ruoyi.zsyh.service.IZsyhPlatformSellpartsspecialService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 商城活动商品Controller
 * 
 * @author yuexl
 * @date 2025-04-27
 */
@Controller
@RequestMapping("/zsyh/sellPartsSpecial")
public class ZsyhPlatformSellpartsspecialController extends BaseController
{
    private String prefix = "zsyh/sellPartsSpecial";

    @Autowired
    private IZsyhPlatformSellpartsspecialService zsyhPlatformSellpartsspecialService;

    @RequiresPermissions("zsyh:sellPartsSpecial:view")
    @GetMapping()
    public String sellPartsSpecial()
    {
        return prefix + "/sellPartsSpecial";
    }

    /**
     * 查询商城活动商品列表
     */
    @RequiresPermissions("zsyh:sellPartsSpecial:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhPlatformSellpartsspecial zsyhPlatformSellpartsspecial)
    {
        startPage();
        List<ZsyhPlatformSellpartsspecial> list = zsyhPlatformSellpartsspecialService.selectZsyhPlatformSellpartsspecialList(zsyhPlatformSellpartsspecial);
        return getDataTable(list);
    }

    /**
     * 导出商城活动商品列表
     */
    @RequiresPermissions("zsyh:sellPartsSpecial:export")
    @Log(title = "商城活动商品", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhPlatformSellpartsspecial zsyhPlatformSellpartsspecial)
    {
        List<ZsyhPlatformSellpartsspecial> list = zsyhPlatformSellpartsspecialService.selectZsyhPlatformSellpartsspecialList(zsyhPlatformSellpartsspecial);
        ExcelUtil<ZsyhPlatformSellpartsspecial> util = new ExcelUtil<ZsyhPlatformSellpartsspecial>(ZsyhPlatformSellpartsspecial.class);
        return util.exportExcel(list, "商城活动商品数据");
    }

    /**
     * 新增商城活动商品
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存商城活动商品
     */
    @RequiresPermissions("zsyh:sellPartsSpecial:add")
    @Log(title = "商城活动商品", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhPlatformSellpartsspecial zsyhPlatformSellpartsspecial)
    {
        return toAjax(zsyhPlatformSellpartsspecialService.insertZsyhPlatformSellpartsspecial(zsyhPlatformSellpartsspecial));
    }

    /**
     * 修改商城活动商品
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ZsyhPlatformSellpartsspecial zsyhPlatformSellpartsspecial = zsyhPlatformSellpartsspecialService.selectZsyhPlatformSellpartsspecialById(id);
        mmap.put("zsyhPlatformSellpartsspecial", zsyhPlatformSellpartsspecial);
        return prefix + "/edit";
    }

    /**
     * 修改保存商城活动商品
     */
    @RequiresPermissions("zsyh:sellPartsSpecial:edit")
    @Log(title = "商城活动商品", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhPlatformSellpartsspecial zsyhPlatformSellpartsspecial)
    {
        return toAjax(zsyhPlatformSellpartsspecialService.updateZsyhPlatformSellpartsspecial(zsyhPlatformSellpartsspecial));
    }

    /**
     * 删除商城活动商品
     */
    @RequiresPermissions("zsyh:sellPartsSpecial:remove")
    @Log(title = "商城活动商品", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhPlatformSellpartsspecialService.deleteZsyhPlatformSellpartsspecialByIds(ids));
    }
}
